// token 3个操作 - 存储/获取/删除
const HMTT_TOKEN = 'HMTT_TOKEN'
// 1. 存储 token
export const setToken = (token) => localStorage.setItem(HMTT_TOKEN, token)

// 2. 获取 token
export const getToken = () => localStorage.getItem(HMTT_TOKEN)


// 3. 删除 token
export const removeToken = () => localStorage.removeItem(HMTT_TOKEN)


// 🔔小技巧：手打上面封装的函数名，VsCode 会有自动导入的提示。

// 本地存储已关注的栏目 3个操作 - 存储/获取/删除
const HMTT_FOLLOW_CATE = 'HMTT_FOLLOW_CATE'
// 1. 存储 followCate  --数组
export const setFollowCate = (followCate) => localStorage.setItem(HMTT_FOLLOW_CATE, JSON.stringify(followCate))

// 2. 获取 followCate  注意这里没有写花括号，因为要 return 获取到的 cate - 数组
export const getFollowCate = () => JSON.parse(localStorage.getItem(HMTT_FOLLOW_CATE)) || []


// 3. 删除 followCate
export const removeFollowCate = () => localStorage.removeItem(HMTT_FOLLOW_CATE)

// 本地存储未关注的栏目 3个操作 - 存储/获取/删除
const HMTT_UNFOLLOW_CATE = 'HMTT_UNFOLLOW_CATE'
// 1. 存储 unfollowCate  --数组
export const setUnfollowCate = (unfollowCate) => localStorage.setItem(HMTT_UNFOLLOW_CATE, JSON.stringify(unfollowCate))

// 2. 获取 unfollowCate  注意这里没有写花括号，因为要 return 获取到的 cate - 数组
export const getUnfollowCate = () => JSON.parse(localStorage.getItem(HMTT_UNFOLLOW_CATE)) || []


// 3. 删除 unfollowCate
export const removeUnfollowCate = () => localStorage.removeItem(HMTT_UNFOLLOW_CATE)

// 历史记录
const HMTT_SEARCH_KEYWORD = 'HMTT_SEARCH_KEYWORD'
export const setSearchKeyword = (SearchKeyword) => localStorage.setItem(HMTT_SEARCH_KEYWORD, JSON.stringify(SearchKeyword))
export const getSearchKeyword = () => JSON.parse(localStorage.getItem(HMTT_SEARCH_KEYWORD)) || []
export const removeSearchKeyword = () => localStorage.removeItem(HMTT_SEARCH_KEYWORD)

// 本地id
const HMTT_USER_ID = 'HMTT_USER_ID'
export const setUserID = (UserID) => localStorage.setItem(HMTT_USER_ID, JSON.stringify(UserID))
export const getUserID = () => JSON.parse(localStorage.getItem(HMTT_USER_ID))
export const removeUserID = () => localStorage.removeItem(HMTT_USER_ID)